home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / icast.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  852 b   |  34 lines

  1. /*
  2.                                     I C A S T . C
  3. */
  4.  
  5. #include "iccomp.h"
  6.  
  7. ESTRUC_ *icast(e)
  8.     ESTRUC_
  9.         *e;
  10. {
  11.     if (test_type(e, e_list))               /* (int)list not ok */
  12.     {
  13.         semantic(illegal_cast);
  14.         discard(e);
  15.         set_type(e, e_int | e_const);
  16.     }
  17.     else if (test_type(e, e_str))           /* (int)string ok */
  18.     {
  19.         if (test_type(e, e_const))          /* string const to a */
  20.         {
  21.             e->evalue =                      /* convert to string */
  22.                 atoi(stringtab[e->evalue].string);
  23.             set_type(e, e_const | e_int);
  24.         }
  25.         else
  26.         {
  27.             etoc(e);                        /* convert to code */
  28.             gencode(e, op_atoi);            /* runtime conversion needed */
  29.             set_type(e, e_int | e_code);
  30.         }
  31.     }
  32.     return (e);
  33. }
  34.